var ByteBuffer = require('dena-bytebuffer');
//旧的new Buffer(size)
var msg1 =new Buffer(10).fill(0);//<Buffer 30 cd 51 00 00 00 00 00 c0 69>
console.log(msg1);
//新的Buffer.alloc(size)
var msg11 =Buffer.alloc(10);  //等于new Buffer(10).fill(0)
console.log(msg11);

//旧的new Buffer(bufer)
var msg2 =new Buffer("hello world node.js");
console.log("msg2:",msg2);
//新的Buffer.from(bufer)
var msg22 =Buffer.from("hello world node.js");
if(msg22.length ===19){
    console.log(msg22);//<Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64 20 6e 6f 64 65 2e 6a 73>
}
//长度验证
if(msg22.length-msg2.length ===0){
    console.log("ok")
}


//内存切片
var buf1 = new Buffer("hahahah");
var buf2 =buf1.slice(6);
console.log(buf1)
console.log(buf2)
//<Buffer 68 61 68 61 68 61 68>
//<Buffer 61 68 61 68 61 68>